import { Controller } from 'egg';

export default class HomeController extends Controller {
    public async index() {
        const { ctx } = this;
        ctx.body = await ctx.service.test.sayHi('egg');
    }

    // 每日推荐歌曲
    public async resource() {
        const url = `/weapi/v1/discovery/recommend/resource`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', {})
        const { body } = result;
        this.ctx.body = body;
    }

    // 每日推荐歌单
    public async music() {
        const data = {
            offset: 0,
            total: true,
            limit: 20,
        }
        const url = `/weapi/v1/discovery/recommend/songs`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', data)
        const { body } = result;
        this.ctx.body = body;
    }
    // 推荐MV
    public async mv() {
        const url = `/weapi/personalized/mv`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', {})
        this.ctx.body = result.body;
    }

    // 推荐歌单
    public async playlist() {
        const { offset, limit } = this.ctx.query;
        const data = {
            limit: limit || 30,
            offset: offset || 0,
            total: true,
            n: 1000,
        }
        const url = `/weapi/personalized/playlist`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', data)
        this.ctx.body = result.body;
    }
    // 推荐音乐
    public async newsong() {
        const data = {
            type: "recommend"
        };
        const url = `/weapi/personalized/newsong`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', data)
        this.ctx.body = result.body;
    }
    // d推荐电台
    public async djprogram(){
        const data = {};
        const url = `/weapi/personalized/djprogram`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', data)
        this.ctx.body = result.body;
    }
    // 推荐节目 
    public async program(){
        const data = {cateId:this.ctx.query.type};
        const url = `/weapi/program/recommend/v1`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', data)
        this.ctx.body = result.body;
    }
    // 独家放送
    public async privatecontent(){
        const url = `/weapi/personalized/privatecontent`;
        let result = await this.service.mequest.createWebAPIRequest(url, 'POST', {})
        this.ctx.body = result.body;
    }

}
